<?php

/**
 * @name Object
 * @author Roman Metlinskyi
 */

class Object
{
  protected static $types = array();

  public function Type($name = __CLASS__){

    if( !isset(self::$types[$name])){
      self::$types[$name] = new Type($name);
    }

    return self::$types[$name];
  }

  public function __get($name)
  {
    $method = "get{$name}";
    if (method_exists($this, $method))
      return $this->$method();

    return null;
  }

  public function __set($name, $value)
  {
    $method = "set{$name}";
    if (method_exists($this, $method))
      return $this->$method($value);

    return null;
  }

  public function __call($name, $args)
  {
    $method = "get{$name}";
    if (method_exists($this, $method))
      return call_user_func_array(array($this, $method),$args);

    return null;
  }


}